#include <bits/stdc++.h>
#include <unordered_map>

using namespace std;

class Solution {
public:
    int minimumOperations(vector<int>& nums)
    {
	int leng = size(nums), res /* = leng & 1 ? 1 : 0 */, maxFreqNum[2];
	unordered_map<int, int> freq[2];
	for (int i = 0; i < leng; ++i) {
	    int round = i & 1;
	    if (++freq[round][nums[i]] > freq[round][maxFreqNum[round]]) maxFreqNum[round] = nums[i];
	}
	res = leng - freq[0][maxFreqNum[0]] - freq[1][maxFreqNum[1]];
	if (maxFreqNum[0] != maxFreqNum[1]) return res;

	int diff = INT_MAX;
	for (int round : { 0, 1 }) {
	    int oMax = freq[round][maxFreqNum[round]];
	    for (auto [key, val]: freq[round]) {
		int cDiff = oMax - val;
		if (cDiff == 0) {
		    if (key != maxFreqNum[round]) return res;
		} else diff = min(diff, cDiff);
	    }
	}
	return res + diff;
    }

private:
};

int main()
{
    [[maybe_unused]] Solution solution;
    return 0;
}
